package com.maple.phoneward.activity;

import java.util.Timer;
import java.util.TimerTask;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.widget.LinearLayout;

import com.maple.phoneward.utils.AppUtil;
import com.maple.phoneward.utils.Logger;

/**
 * MainActivity.java
 * 
 * @author YaJian Qiu
 * @time 2013-3-17 下午8:30:29<br>
 *       本类描述：欢迎界面
 * 
 */
public class WelcomeActivity extends Activity {

	private static final String TAG = "WelcomeActivity";

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		AppUtil.setFullScreen(this);// 设置全屏显示
		LinearLayout layout = new LinearLayout(this);// 创建布局
		layout.setBackgroundResource(R.drawable.welcome);// 设置背景图片
		setContentView(layout);

		Timer timer = new Timer();// 创建定时器，3000ms后结束当前Activity
		timer.schedule(new TimerTask() {

			@Override
			public void run() {
				WelcomeActivity.this.finish();
				// 启动应用主界面
				Intent intent = new Intent(WelcomeActivity.this, LockPatternActivity.class);
				startActivity(intent);
				Logger.d(TAG, "结束欢迎界面，进入屏幕锁定界面");
			}
		}, 3000);
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		// 在欢迎界面时屏蔽返回键
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			return true;
		}
		return super.onKeyDown(keyCode, event);
	}

}
